# 面向对象特性
# 一、封装

# 定义私有成员
# 在变量或者方法名称以__开头
class Phone:
    __current_voltage = None

    def set_cv(self, val):
        self.__current_voltage = val

    def __keep_single_core(self):
        print("cpu以单核模式运行")

    def call_by_5g(self):
        if self.__current_voltage >= 1:
            print("5g通话已开启")
        else:
            print("电量不足, 无法使用5g通话")
            self.__keep_single_core()


phone = Phone()
# phone.__current_voltage = 3  # 不会报错, 相当于给phone创建一个成员变量
# phone.__keep_single_core()
phone.set_cv(1)
phone.call_by_5g()
phone.set_cv(0.5)
phone.call_by_5g()
